//按需导出
export function setName(uname) {
  console.log(uname)
}

//向外导出setName方法 默认导出
// export default setName

export const deepClone = function (oldData, newData) {
  for (let key in oldData) {
    if (getType(oldData[key]) === 'Array') {
      newData[key] = []
      deepClone(oldData[key], newData[key])
    } else if (getType(oldData[key]) === 'Object') {
      newData[key] = {}
      deepClone(oldData[key], newData[key])
    } else {
      newData[key] = oldData[key]
    }
  }
}

export const getType = function (data) {
  const type = Object.prototype.toString.call(data)

  switch (type) {
    case '[object Object]':
      return 'Object'
    case '[object Array]':
      return 'Array'
    case '[object Function]':
      return 'Function'
    case '[object Number]':
      return 'Number'
    case '[object String]':
      return 'String'
    case '[object Boolean]':
      return 'Boolean'
    case '[object Null]':
      return 'Null'
    case '[object Undefined]':
      return 'Undefined'
    case '[object Symbol]':
      return 'Symbol'
    case '[object RegExp]':
      return 'RegExp'
    case '[object Map]':
      return 'Map'
    case '[object Set]':
      return 'Map'

    default:
      throw new Error('未见过的类型')
  }
}

export const DEV_MODE = 'devlopment'
